package main

import (
	"net"
	"net/rpc"
	"shop/grpc_test/serv/inter"
)

type HelloService struct{}

func (s *HelloService) Hello(req string, reply *string) error {
	*reply = "hello" + req
	return nil
}

var _ inter.HelloService = (*HelloService)(nil)

func main() {
	rpc.RegisterName(inter.HelloServiceName, new(HelloService))

	listen, err := net.Listen("tcp", ":8888")
	if err != nil {
		panic("listen" + err.Error())
	}

	for {
		conn, err := listen.Accept()
		if err != nil {
			panic("accept" + err.Error())
		}

		go rpc.ServeConn(conn)
	}
}
